package com.syni.mdd.sjb.common.datatreaure.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.syni.mdd.sjb.common.component.mybatis.dxshapp.entity.BmsBusinessInfo;
import com.syni.mdd.sjb.common.component.mybatis.dxshapp.mapper.BmsBusinessInfoMapper;
import com.syni.mdd.sjb.common.datatreaure.service.BmsBusinessInfoService;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * <p>
 * 店铺支付信息绑定表 服务实现类
 * </p>
 *
 * @author lcc
 * @since 2020-05-31
 */
@Service
public class BmsBusinessInfoServiceImpl extends ServiceImpl<BmsBusinessInfoMapper, BmsBusinessInfo> implements BmsBusinessInfoService {
    @Autowired
    BmsBusinessInfoMapper bmsBusinessInfoMapper;

    @Override
    public BmsBusinessInfo getBusinessInfoByBusinessId(Integer bmsBusinessId) {
        return bmsBusinessInfoMapper.selectById(bmsBusinessId);
    }

    @Override
    public Map<Integer, BmsBusinessInfo> getMapByBusinessIds(Set<Integer> bmsBusinessId) {
        Map<Integer, BmsBusinessInfo> map = new HashMap<>();
        if(bmsBusinessId.size() > 0){
            QueryWrapper queryWrapper = new QueryWrapper();
            queryWrapper.in(BmsBusinessInfo.BUSINESS_ID,bmsBusinessId);
            List<BmsBusinessInfo> bmsBusinessInfos = bmsBusinessInfoMapper.selectList(queryWrapper);
            if(CollectionUtils.isNotEmpty(bmsBusinessInfos)){
                for(BmsBusinessInfo bmsBusinessInfo : bmsBusinessInfos){
                    map.put(bmsBusinessInfo.getBusinessId(),bmsBusinessInfo);
                }
            }
        }
        return map;
    }
}
